package test.format_test;

import java.lang.annotation.*;
import java.lang.reflect.Method;

//注解用于方法
@Target(ElementType.METHOD)
//运行时使用
@Retention(RetentionPolicy.RUNTIME)
public @interface ForAnnotation {
    String name();
}


class TestMain{
    public static void main(String[] args) throws Exception {
        new TestAnno().hh();
        Class cls = Class.forName("test.format_test.TestAnno");
        Method m = cls.getMethod("hh");
        Annotation Anno = m.getAnnotation(ForAnnotation.class);
        System.out.println(((ForAnnotation) Anno).name());
    }
}

class TestAnno{
    @ForAnnotation(name = "TestA")
    public void hh(){
        System.out.println("hello");
    }
}